<?php
echo $this->Form->create('management', array('class' => 'form-horizontal'));
?>
<div class="control-group">
	<div class="controls">
		<label class="control-label" >Function:</label>
		<div class="controls">
			<?php 
			echo $this->Form->select('function', array(), array('id' => 'select1' , 'style' => 'width:180px'));
			?>
			<span style = "float:right; width = 50">
			<?php
				echo $this->Html->link('<i class = "icon-plus icon-white"></i>Add Screen',
					'#', 
					array('class' => 'btn btn-info btn-action', 'div' => false, 'id' => 'btn_add', 'escape' => false )); 
			?>
			</span>
		</div>
		<br>
		<label class="control-label" >Test version:</label>
		 <div class="controls">
			<?php 
			echo $this->Form->select('test_version', array(), array('id' => 'select2', 'style' => 'width:180px'));
			?>
			<span style = "float:right; width = 50">
			<?php 
			echo $this->Form->button('<i class = "icon-search icon-black"></i>&nbspSearch', array('class' => 'btn', 'div' => false, 'style' => "width: 115px" ));
			?>
			</span>
		</div>
	</div>
</div>
<?php 
echo $this->Form->end(); 
?>
<table>
  <tr>
    <td>
    	<?php
		echo $this->Html->link('<i class = "icon-trash icon-white"></i>&nbspDelete',
			array('controller' => 'management', 'action' => '#'),
			array('class' => 'delete btn btn-danger btn-action ', 'escape' => false)); 
		?>
		&nbsp;
    </td>
    
    <td>
    	<?php
		echo $this->Html->link('Export CSV',
			array('controller' => 'management', 'action' => '#'),
			array('class' => 'btn btn-info btn-action' )); 
		?>
		&nbsp;
    </td>
    <td>
    	<?php
		echo $this->Html->link('Import CSV',
			array('controller' => 'management', 'action' => '#'),
			array('class' => 'btn btn-info btn-action')); 
		?>
    </td>
  </tr>
</table>


<?php
	echo $this->Form->create('from');
?>

<table class="table table-bordered table-striped no-margin" id="table" >
	<thead >
		<tr style = " background: #eeeeee; color: green; font-size: 15px" height = 50>
			<th>
			<?php echo $this->Form->checkbox('selectAll', array('id'=>'checkall'));?>
			</th>
			<th>Screen Name</th>
			<th>Screen Code</th>
			<th>Total TC Num</th>
			<th>Tested Num</th>
			<th>Bug Num</th>
			<th>Unclear Num</th>
			<th>Finish Rate</th>
			<th>Action</th>
		</tr>
	</thead>
	<tbody>
		<?php for ($i = 1; $i <= 6; $i++):?>
		<tr>
			<td><?php echo $this->Form->checkbox('selectAll', array('id'=>'checkall1'));?></td>
			<td>Registration</td>
			<td>RG001</td>
			<td>200</td>
			<td>50</td>
			<td>10</td>
			<td>20</td>
			<td>30%</td>
			<td>
			<?php
				echo $this->Html->link($this->Html->image('add.png', array('width' => "18px")),
					array('controller' => 'management', 'action' => 'add_area'),
					array('div' => false, 'escape' => false  )); 
			?>
			<?php 
				echo $this->Html->link($this->Html->image('edit.png', array('width' => "18px")), "javascript:void(0);", array('class' =>'btn_edit',  'id' => 'van', 'escape' => false)); 
			?>
			
			<?php
				echo $this->Html->link($this->Html->image('delete.png', array('width' => "18px") ),
					array('controller' => 'management', 'action' => '#'),
					array('div' => false, 'escape' => false )); 
			?>
			</td>
		</tr>
		<?php endfor;?>
	</tbody>
</table>
<?php 
echo $this->Form->end(); 
?>

<table>
  <tr>
    <td>
    	<?php
		echo $this->Html->link('<i class = "icon-trash icon-white"></i>&nbspDelete',
			array('controller' => 'management', 'action' => '#'),
			array('class' => 'delete btn btn-danger btn-action ', 'escape' => false)); 
		?>
		&nbsp;
    </td>
    <td>
    	<?php
		echo $this->Html->link('Export CSV',
			array('controller' => 'management', 'action' => '#'),
			array('class' => 'btn btn-info btn-action' )); 
		?>
		&nbsp;
    </td>
    <td>
    	<?php
		echo $this->Html->link('Import CSV',
			array('controller' => 'management', 'action' => '#'),
			array('class' => 'btn btn-info btn-action')); 
		?>
    </td>
  </tr>
</table>
<script type="text/javascript">
	function countChecked() {
		var count = 0;
		$('input[type="checkbox"]').each(function(){            
	        if (this.id.indexOf("checkall1") == 0 && this.checked == 1) {
	            count++
	        }
	     });
	
	    return count;
	}
	$(document).ready(function() {
		var oTable = $("#table").dataTable({
				"sScrollX" : "100%",
				"sScrollY" : 310,
				"sScrollInner" : "110%",
				"bScrollCollapse" : false,
				"bPaginate" : false,
				"bFilter" : false,
				"bInfo" : false,
				"bSort" : false
			});
		// chon selectall
		$("#checkall").click(function(){
            var checked_status = this.checked;
            $('input[type="checkbox"]').each(function(){            
               if (this.id.indexOf("checkall1") == 0) {
                   this.checked = checked_status;
               }
            });
            
        });
        $(".delete").click(function(){
            if (countChecked() == 0){
            	$("#popup_msg").bPopup();
    			return false;
            }
        });
        $('.close').click(function(){
			$('#popup_msg').bPopup().close();
		});
		// them screen
		$('#btn_add').click(function(){	 
			$('#popup_add').bPopup({
				positionStyle: 'fixed',
				modalColor: '#333333',
				transition: 'slideDown'
			})
		});
		$('.close').click(function(){
			$('#popup_add').bPopup().close();
		});
		// edit Screen
		$('a.btn_edit').live("click",function(){
			var id = $(this).attr('id');
			var url = "/test_case/management/edit_screen/" + id;
			$('#popup_edit').bPopup({
				positionStyle: 'fixed',	
				modalColor: '#333333',
				transition: 'slideDown',	
				contentContainer:'.content_edit',
				loadUrl: url
			});			
		});
		$(".close").click(function(){
			$("#popup_edit").bPopup().close();
		});
		
	});
	// select 2 cho text tìm kiếm
	$("#select1").select2({
        placeholder: "Selection...",
        
    });
	$("#select2").select2({
        placeholder: "Selection...",
        
    });
</script>

<div id="popup_edit" style = "width: 450px" class ="popup" >
	<div class="modal-header " align ="center" style = "color: green">
	    <button type="button" class="close " data-dismiss="modal" >&times;</button>
	    <h3>Edit Screen</h3>
 	 </div>
	<br>
	<div class="content_edit" ></div>
</div>

<div id="popup_add" style = "width: 450px" class ="popup">
	
	<div class="modal-header" align ="center" style = "color: green">
	    <button type="button" class="close" data-dismiss="modal" >&times;</button>
	    <h3>Add Screen</h3>
 	 </div>
	<br>
	<?php echo $this->Form->create('addscreen', array('class' => "form-horizontal"));?>
	  <div class="control-group">
	    <label class="control-label" >Function Name</label>
	    <div class="controls">
	      <?php echo $this->Form->input('functionName', array('label' => false));?>
	    </div>
	  </div>
	  <div class="control-group">
	    <label class="control-label">Screen Name(Ja)</label>
	    <div class="controls">
	      <?php echo $this->Form->input('screenName1', array('label' => false));?>
	    </div>
	  </div>
	  <div class="control-group">
	    <label class="control-label" >Screen Name(En)</label>
	    <div class="controls">
	      <?php echo $this->Form->input('screenName2', array('label' => false));?>
	    </div>
	  </div>
	  <div class="control-group">
	    <label class="control-label">Screen Name(Vi)</label>
	    <div class="controls">
	      <?php echo $this->Form->input('screenName3', array('label' => false));?>
	    </div>
	  </div>
	  <div class="control-group">
	    <label class="control-label" >Screen Code</label>
	    <div class="controls">
	      <?php echo $this->Form->input('screenCode', array('label' => false));?>
	    </div>
	  </div>
	  <div class="modal-footer" >
	     <div align = "center">
	     <?php echo $this->Form->button('Save', array('class' => "btn btn-primary"))?>
	     </div> 
	  </div>
	<?php echo $this->Form->end();?>

</div>

<div id = "popup_msg" class ="popup" style = "width: 400px">
	<div class="modal-header" align ="center" style = "color: green">
	    <button type="button" class="close" data-dismiss="modal" >&times;</button>
	    <?php echo $this->Html->image('msg.png', array('style' => 'width: 80px'));?>
	    <h3>Please select at last 1 record!</h3>
 	 </div>
	<br>
	
</div>
